cached-webpgr.js icon indicating copy to clipboard operation
cached-webpgr.js copied to clipboard

Update/add

Open WarManiac opened this issue 8 years ago • 6 comments

Update/add: add localStorage check -> _loadScript(...) change for support no local localStorage add support for css file add all callback's are worked on when (xmlhttp.status != 200) in _cacheScript()

WarManiac avatar Aug 22 '17 03:08 WarManiac

Very neet to add css support, but this pull request breaks the callback:

      requireScript('jquery', '3.5.1', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js', false, function () {
        requireScript('bootstrap', '4.5.3', 'js/bootstrap.bundle.min.js');
      });

Gives an error ReferenceError: $ is not defined[Learn More]. I have to refresh the page for it to work.

However it works ok without a callback

requireScript('jquery', '3.5.1', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js')
requireScript('bootstrap', '4.5.3', 'js/bootstrap.bundle.min.js');

Jolly-Pirate avatar Oct 25 '20 17:10 Jolly-Pirate

requireScript('jquery', '3.5.1', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js', false, function () { requireScript('bootstrap', '4.5.3', 'js/bootstrap.bundle.min.js', false); }); pls test this! $Boolean = false = js $Boolean = frue = css requireScript($Name, $Version, $Url, $Boolean, function () { requireScript($Name, $Version, $Url, $Boolean); });

WarManiac avatar Oct 26 '20 01:10 WarManiac

Using your latest code, adding the boolean didn't matter (it's good to add it anyways). If I put the callback block at the top of all the other scripts (which are not loaded by requireScript), then it works right away. But if the block is after those scripts, then the problem arises and requires a refresh. Weird.

Also, keep in mind to do a localStorage.clear() when you're testing.

Jolly-Pirate avatar Oct 26 '20 04:10 Jolly-Pirate

not localStorage.clear() over F12, manuel clear localStorage (IE, Chrome, FF) and load page new

when load the page: this is my code an not in console ReferenceError: $ is not defined[Learn More] and not a alert.

when press "Home" or "Options" on link alert

<script type="text/javascript">
            requireScript('BO', '0.0.1', 'themes/BO.min.css',true,
                function(){requireScript('jquery.mobile.icons.min.css', '0.0.1', 'themes/jquery.mobile.icons.min.css', true,
                    function(){requireScript('jquery.mobile.structure', '1.4.5', 'jquery.mobile.structure-1.4.5.min.css', true,
                        function(){requireScript('jquery', '1.11.1', 'jquery-1.11.1.min.js',false,
                            function(){requireScript('jquery.mobile', '1.4.5', 'jquery.mobile-1.4.5.min.js', false)
                                      })
                                  })
                              })
                          }
                         )
            window.onload = function() {
                if (!window.jQuery) {  
                    alert('jQuery');
                } else {
                    $('a').click(function() {
                        alert( "Handler for .click() called." );
                    });                    
                }
                
            }
</script>

html

	<body>
	<div data-role="header" style="overflow:hidden;">
	<h1>TEST</h1>
        <a href="#" data-icon="bullets" class="ui-btn-left">Home</a>
		<a href="#" data-icon="gear" class="ui-btn-right">Options</a>
	</div><!-- /header -->
	</body>

WarManiac avatar Oct 26 '20 10:10 WarManiac

my Load Order :

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test</title>
<script type="text/javascript">
 cached-webpgr
 requireScript CSS, CSS, ..., JS, JS, ...
 window.onload = function() {
   $().xyz(function(){ code });
   function abc() { code }
 }
</script>
</head>
<body> html code. i use not script in body or end! Is in localStorage!
</body>
</html>

WarManiac avatar Oct 26 '20 11:10 WarManiac

Hey guys, I really appreciate your effort. As you can see, I have not worked on this project for a loooooong time. But the moment is good so I will have a look in the next weeks and join the discussion. Sory the time frame is not a bit more tight, but the situation dictates it.

select avatar Nov 10 '20 19:11 select