Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Files are being loaded twice #82

Open
pbedi opened this issue Jun 26, 2017 · 3 comments
Open

Files are being loaded twice #82

pbedi opened this issue Jun 26, 2017 · 3 comments

Comments

@pbedi
Copy link

pbedi commented Jun 26, 2017

Hi
As I used the library as explained but my files are being loaded twice,
here is the code:
fallback.load({
BSCSS:['https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
'assets/css/bootstrap.min.css'],
jQuery: [
'//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
'//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js',
'/assets/js/jquery.min.js'],
BSJS:['https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
//'assets/js/bootstrap337/bootstrap.min.js'],
'jQuery.ui': [
'//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js',
'//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js',
'/assets/js/jquery-ui.min.js'],
page_css: ['/subsites/oxtedgasholder/assets/css/main.css?v=1.85'],
'jQuery.validate':['/assets/js/jquery.validate.min.js'],
formValidation:'/assets/js/planningsites/formValidation.js?v=1.85',
sitejs: ['/subsites/oxtedgasholder/assets/js/site.js?v=1.85'],
}, {
// Shim jQuery UI so that it will only load after jQuery has completed!
shim: {
'BSJS': ['jQuery'],
'jQuery.ui': ['jQuery'],
jQuery.validate': ['jQuery'],
'formValidation':['jQuery'],
'sitejs': 'formValidation'
},

	callback: function(success, failed) {
		// success - object containing all libraries that loaded successfully.
		// failed - object containing all libraries that failed to load.
						
		// All of my libraries have finished loading!
		// Execute my code that applies to all of my libraries here!
						
		}
});
			
fallback.ready(['jQuery'], function() {
	// jQuery Finished Loading
					
	// Execute my jQuery dependent code here!
});
			
fallback.ready(function() {
	// All of my libraries have finished loading!
			
	// Execute my code that applies to all of my libraries here!
});

HERE is the output copied from browser network tab
image
Please let me know, if I am doing anything wrong.
Thanks in advance.
Philip

@ktrubin
Copy link

ktrubin commented Feb 19, 2018

Hi, you should use the correct library alias, which identify library through window.library_alias property

@kolbma
Copy link

kolbma commented Jun 22, 2018

I've the same problem with many javascript files which are extending jQuery with a style like

(function($) { })(jQuery);

So there is no window.library_alias...
For example bootstrap does this. What is the specifier for bootstrap? I've tried jQuery.scrollspy because this is the first not found function of bootstrap.
But bootstrap.min.js get's loaded from all specified urls.

@moving-bits
Copy link

You need to use a function / class or variable name which is defined when the script or css file was loaded successfully, but isn't defined before.

I'm using bootstrap.bundle.min.js with "jQuery.fn.popover" as selector (instead of "BSJS" as in the thread opener's post). [tested with fallback v1.1.9]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants