{"action":"created","issue":{"url":"https://api.github.com/repos/electron/electron/issues/345","repository_url":"https://api.github.com/repos/electron/electron","labels_url":"https://api.github.com/repos/electron/electron/issues/345/labels{/name}","comments_url":"https://api.github.com/repos/electron/electron/issues/345/comments","events_url":"https://api.github.com/repos/electron/electron/issues/345/events","html_url":"https://github.com/electron/electron/issues/345","id":34066511,"number":345,"title":"jQuery issue on render side","user":{"login":"deecoolist","id":3056757,"avatar_url":"https://avatars.githubusercontent.com/u/3056757?v=3","gravatar_id":"","url":"https://api.github.com/users/deecoolist","html_url":"https://github.com/deecoolist","followers_url":"https://api.github.com/users/deecoolist/followers","following_url":"https://api.github.com/users/deecoolist/following{/other_user}","gists_url":"https://api.github.com/users/deecoolist/gists{/gist_id}","starred_url":"https://api.github.com/users/deecoolist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deecoolist/subscriptions","organizations_url":"https://api.github.com/users/deecoolist/orgs","repos_url":"https://api.github.com/users/deecoolist/repos","events_url":"https://api.github.com/users/deecoolist/events{/privacy}","received_events_url":"https://api.github.com/users/deecoolist/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/electron/electron/labels/discussion","name":"discussion","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2014-05-22T09:51:26Z","updated_at":"2016-05-18T15:12:43Z","closed_at":"2014-05-24T08:11:14Z","body":"everytime loading jquery from render side (any.html) via dom ``` <script src=\"jquery.js\"></script> ``` resulting _\"Uncaught ReferenceError: jQuery is not defined\"_ or _\"Uncaught Error: ... requires jQuery\"_;\r\n\r\nbut if I load jQuery via require:\r\n```html\r\n<script>\r\nvar $ = jQuery = require('jquery'); // as node_modules\r\n/*\r\n * or localy load.\r\n * var $ = jQuery = require('./jquery');\r\n */\r\n</script>\r\n```\r\n(on every page) It was fine!, but module.exports get polluted by jQuery's methods\r\n\r\nso every page either local or external site whom use jQuery would fail to properly load since jQuery header:\r\n```javascript\r\n(function( global, factory ) {\r\n\r\n\tif ( typeof module === \"object\" && typeof module.exports === \"object\" ) {\r\n\t\t// For CommonJS and CommonJS-like environments where a proper window is present,\r\n\t\t// execute the factory and get jQuery\r\n\t\t// For environments that do not inherently posses a window with a document\r\n\t\t// (such as Node.js), expose a jQuery-making factory as module.exports\r\n\t\t// This accentuates the need for the creation of a real window\r\n\t\t// e.g. var jQuery = require(\"jquery\")(window);\r\n\t\t// See ticket #14549 for more info\r\n\t\tmodule.exports = global.document ?\r\n\t\t\tfactory( global, true ) :\r\n\t\t\tfunction( w ) {\r\n\t\t\t\tif ( !w.document ) {\r\n\t\t\t\t\tthrow new Error( \"jQuery requires a window with a document\" );\r\n\t\t\t\t}\r\n\t\t\t\treturn factory( w );\r\n\t\t\t};\r\n\t} else {\r\n\t\tfactory( global );\r\n\t}\r\n\r\n// Pass this if window is not defined yet\r\n}(typeof window !== \"undefined\" ? window : this, function( window, noGlobal ) {\r\n```\r\n\r\nare they any solution for this kind of matter?\r\nThanks."},"comment":{"url":"https://api.github.com/repos/electron/electron/issues/comments/220058448","html_url":"https://github.com/electron/electron/issues/345#issuecomment-220058448","issue_url":"https://api.github.com/repos/electron/electron/issues/345","id":220058448,"user":{"login":"mendo-","id":6099519,"avatar_url":"https://avatars.githubusercontent.com/u/6099519?v=3","gravatar_id":"","url":"https://api.github.com/users/mendo-","html_url":"https://github.com/mendo-","followers_url":"https://api.github.com/users/mendo-/followers","following_url":"https://api.github.com/users/mendo-/following{/other_user}","gists_url":"https://api.github.com/users/mendo-/gists{/gist_id}","starred_url":"https://api.github.com/users/mendo-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mendo-/subscriptions","organizations_url":"https://api.github.com/users/mendo-/orgs","repos_url":"https://api.github.com/users/mendo-/repos","events_url":"https://api.github.com/users/mendo-/events{/privacy}","received_events_url":"https://api.github.com/users/mendo-/received_events","type":"User","site_admin":false},"created_at":"2016-05-18T15:12:43Z","updated_at":"2016-05-18T15:12:43Z","body":"I found this worked to load jquery in window of an external website.\r\n\r\nmain.js\r\n\r\n`mainWindow = new BrowserWindow({`\r\n`    webPreferences: {`\r\n`      nodeIntegration: true,`\r\n`      webSecurity: true,`\r\n`      preload: path.resolve(path.join(__dirname, 'path/to/preload.js'))`\r\n`    },`\r\n`  \twidth: 1400,`\r\n`  \theight: 1200`\r\n`  });`\r\n\r\npreload.js\r\n\r\n`document.addEventListener(\"DOMNodeInserted\", function(event) {`\r\n`    if (!!window && !(!!window.$)) {`\r\n`        window.$ = window.jQuery = require('path/to/jquery.js');`\r\n`    }`\r\n`});`"}}