I'm not totally sure I've tracked this to the right spot, but I'm using GM_getResourceText to add some canned CSS which are mostly companions to javascript libraries that I am using through @require.
The main idea is to keep the resources pure and separate so I can easily include them in such a way that would be similar to @require, but targeting .css files. Here's a slimmed down example which exhibits the behavior: // ==UserScript== // @name resourcetest // @namespace resourcetest // @include * // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js // @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/Highcharts-4.0.4/js/highcharts.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/jquery.localScroll.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/jquery.hoverIntent.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/jquery.spellchecker.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/quantities.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/jquery.jqpagination.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/dklib/dklib.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/fixedsticky/fixedsticky.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/tooltipster-master/js/jquery.tooltipster.min.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/jquery.lazyloadxt.js // @require https://dl.dropboxusercontent.com/u/26263360/script/lib/jquery.dragtable.js // @resource buttonCSS https://dl.dropboxusercontent.com/u/26263360/script/css/buttons.css // @resource advCSS https://dl.dropboxusercontent.com/u/26263360/script/css/advancedsearch.css // @resource normalizeCSS http://yui.yahooapis.com/pure/0.5.0/base.css // @resource pureCSS http://yui.yahooapis.com/pure/0.5.0/pure.css // @resource fontAwesomeCSS https://dl.dropboxusercontent.com/u/26263360/script/css/font-awesome.css // @resource stickyCSS https://dl.dropboxusercontent.com/u/26263360/script/lib/fixedsticky/fixedsticky.css // @resource tooltipsterCSS https://dl.dropboxusercontent.com/u/26263360/script/lib/tooltipster-master/css/tooltipster.css // @resource tooltipster-shadowCSS https://dl.dropboxusercontent.com/u/26263360/script/lib/tooltipster-master/css/themes/tooltipster-shadow.css // @run-at document-end // @grant GM_addStyle // @grant GM_xmlhttpRequest // @grant GM_getResourceText // @version 4.0 // ==/UserScript== function addResourceCSS(){ var cssNames = [ "buttonCSS", "advCSS", "normalizeCSS", "pureCSS", "fontAwesomeCSS", "stickyCSS", "tooltipsterCSS", "tooltipster-shadowCSS" ]; for ( var x in cssNames){ console.time(cssNames[x]); var thetext = GM_getResourceText(cssNames[x]); console.timeEnd(cssNames[x]); GM_addStyle(thetext); } } $(document).ready(function(){ console.time('total'); addResourceCSS(); console.timeEnd('total'); }) The output on the console is as follows with the time for GM_getResourceText to execute highlighted in red: 09:58:56.353 total: timer started 09:58:56.354 buttonCSS: timer started 09:58:56.491 buttonCSS: 136.58ms 09:58:56.494 advCSS: timer started 09:58:56.640 advCSS: 146.52ms 09:58:56.643 normalizeCSS: timer started 09:58:56.819 normalizeCSS: 175.89ms 09:58:56.820 pureCSS: timer started 09:58:56.959 pureCSS: 139.33ms 09:58:56.962 fontAwesomeCSS: timer started 09:58:57.219 fontAwesomeCSS: 257.47ms 09:58:57.221 stickyCSS: timer started 09:58:57.378 stickyCSS: 156.79ms 09:58:57.379 tooltipsterCSS: timer started 09:58:57.512 tooltipsterCSS: 133.47ms 09:58:57.513 tooltipster-shadowCSS: timer started 09:58:57.596 tooltipster-shadowCSS: 83.26ms 09:58:57.597 total: 1244.05ms These are indeed fairly large CSS files all-together totaling 158K, but it seems like the getResourceText function is taking an inordinately large amount of time to execute. There seems to be no good correlation or consistancy between the size of each file as and load time different resources will take longer on each run. Concatenating the css files together and calling GM_getResourceText once does decrease the total time, but it's still many hundreds of milliseconds. I've tried this in a new firefox profile with only Greasemonkey installed and I've tried this in a fresh firefox portable installation, but the times remain consistently in the same order of magnitude though they do vary quite a bit. I've tried two other computers with the same result. I also tried it in Tampermonkey for Chrome and the times were all in the low single digit millisecond range. I've had a script using this code out to users for a couple years and while I haven't so precisely instrumented this part of the code, it seems like it has slowed down for me at some point in time. I can't pinpoint when as I was busy with other features. Am I blind to doing something blatantly wrong? Were there some changes in how this function worked in the past year or two? Thanks, Ben -- You received this message because you are subscribed to the Google Groups "greasemonkey-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/greasemonkey-users. For more options, visit https://groups.google.com/d/optout.
