rlr / dotjs-addon

[unmaintained] ~/.js for Firefox
BSD 3-Clause "New" or "Revised" License
144 stars 17 forks source link

CSS isn't loaded if JS errors #44

Closed keith closed 6 years ago

keith commented 8 years ago

I noticed this interesting case that is possibly unintended. If you have JS and CSS for a particular domain, and when loading the JS, it errors, the CSS will never be loaded.

This happens because when the eval fails, the entire load-scripts function bails. We could fix this with a try/catch like this:

diff --git i/data/dotjs.js w/data/dotjs.js
index 97aff6e..ec171ee 100644
--- i/data/dotjs.js
+++ w/data/dotjs.js
@@ -13,7 +13,11 @@
         }

         msg.js.forEach(function(script) {
-            eval(script);
+            try {
+                eval(script);
+            } catch(error) {
+                // Maybe log the error?
+            }
         });

         if (msg.coffee) {

For the JS, and coffee phases. I'm happy to submit a PR for this if it's something you think we should handle. Thanks!

rlr commented 8 years ago

sounds good! If you file the PR, I'll merge it. Thanks!

keith commented 6 years ago

Sorry I never got around to this, closing this now that it's marked as unmaintained.