Loading sitewide Javascript files

Forums Ideas Loading sitewide Javascript files

This topic contains 6 replies, has 4 voices, and was last updated by  rbekar 2 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • rbekar
    Member

    Hi, I’m developing a large site (around 300+ pages), most of these pages make use of a javascript file which I have organised in the assets folder.

    The problem I have is that every page calls to load up every javascript file. For example, my home page uses a couple of javascript files, but the html calls to load every javascript file used on the whole site – up to 300! which has adverse effect on load times.

    I know I could amalgamate all javascript files into one large one, but I’d rather not do this as it’s far easier to edit them as single files allocated to single pages – they will get edited on a regular basis.

    I guess what I’m asking is, can something be done to only load the javascript files that are used on the current page?

    Thanks ion advance

    Jo
    Member
    Valued

    +1 on this and CSS, CDN’s etc. as well. We’ve asked for this for quite some time now, I do hope it’s in the works in one of the upcoming updates soon.

    Removing them via script, for people like me that don’t really know how to use the export script setup, isn’t really an option. And obviously removing them after export would be rediculously tedious work after ever export.

    Would really be nice if only the files for the page itself were linked and nothing more. I thought I had read something quite a while back on it in a discussion about this very thing that they added it to their list possibly with a checkbox thing or way to select which files to include on each page. Guess we’ll see.

    Printninja
    Member

    How about adding the specific javascript to the page using the custom code component?

    Jo
    Member
    Valued

    That works yes, but it’s a work around, and we shouldn’t have to do that 🙂

    Saj
    Member
    Valued

    That’s because you really should be loading a single JS/CSS file so that browser caching works the way it was meant too.

    Saj
    saj.bss.design

    Jo
    Member
    Valued

    I can guarantee you that I will probably “never” have a single JS and CSS file, working that way is pretty much impossible and it’s much easier to deal with things when you know exactly where to find them. Not to mention that every time I’ve tried using the feature in BSS that combines them and minimizes etc. it breaks the site completely. I’ll stay with what I’m comfortable with, and I definitely shouldn’t be penalized for that. 🙂

    rbekar
    Member

    I can combine all my javascript files using a batch command line, but I’d rather not.

    I have everything structures in folders within the assets folder making it easy to locate which javascript file I need to update regularly.

    Surely this could be implemented?

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.