Skip to content

Instantly share code, notes, and snippets.

@LasseRafn
Created March 3, 2017 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LasseRafn/f44c9606733271d97eca50ad88224394 to your computer and use it in GitHub Desktop.
Save LasseRafn/f44c9606733271d97eca50ad88224394 to your computer and use it in GitHub Desktop.

app.js

This file is added ABOVE all other scripts in the HTML

window.$ = window.jQuery = require('jquery');

home.js

This file is loaded below app.js (as stated above)

$("body").html('Testing');

File size for this home.js: ~270kb

However, doing this in home.js:

window.$("body").html('Testing');

Results in below 1kb file size.

The reason? Well if jQuery/$ is not defined, it requires it.. My concern is that it does this, even though its already defined in window.. Seems odd tbh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment