Disabling automatic loading of CSS & JS on page includes

  • 1
  • Idea
  • Updated 4 years ago
  • Under Consideration
Skuid's feature to automatically include JS & CSS (see ) is extremely beneficial.  That said, it comes with some challenges when using features such as Page Includes as, unfortunately, not all javascript, jQuery, etc. is written to properly handle multiple "loads."  Also, browsers like Chrome, etc. have some hidden "tricks" when loading a file multiple times and gaining access to the source in the debug console is not terribly obvious (e.g. Chrome creates VM#### files for secondary copies of js, etc.).  On top of all that, there is a slight performance hit that is unnecessary to incur.

In our particular case, we use multiple third-party libraries that track state and when getting reloaded, lose their state or end up having multiple objects all tracking the same things (e.g mutation events).  Note that we're concat'ing all of these libraries in to a single JS file.

One solution would be to modify all these libraries to "ifdef" around the loading - not ideal because as new versions come out, customization's are required each time to the library.

Would like to see a property added to components (eg. Page Includes) that could result in JS/CSS getting automatically loaded that would instruct skuid to not auto-load <ModuleName>JS & <ModuleName>CSS files.

As always, thanks for considering!
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
Hi Barry,

This is interesting.  What do you think about not having an option at all, but we just add some code that determines if the parent page and the page include are in the same module.  If so, then don't load the <ModuleName>JS and <ModuleName>CSS resources at all for the page include.  I can't see why you would ever want the behavior of them loading twice.
(Edited)
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Hi Ben -

Thanks for considering this.  I thought about your idea as well when writing up the post but then I thought back to a previous community post on "grandfathered" functionality.  If the behavior changes to automatically check and not load it "could" end up causing issues with existing skuid pages.  The chances of this is extremely small I would think since it would be a very rare situation where you would want a JS to load twice but it "could" be something someone out there is banking on on an existing skuid page.  

if this was a net new feature, I'd suggest just auto checking and not loading without providing the option.  If the user really wanted to load a JS twice they could include it on the page include explicitly to trigger the second load.

Personally, I'd be OK with the "auto-check" and not load as you describe.  I think the only thing to consider is backwards compat for the boundary case where someone might actually be taking advantage of the double load.

Thanks again!