| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // reappearing momentarily. | 154 // reappearing momentarily. |
| 155 if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet)) | 155 if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet)) |
| 156 return false; | 156 return false; |
| 157 | 157 |
| 158 // Sometimes the old and new style sheets can be exactly the same. In such a | 158 // Sometimes the old and new style sheets can be exactly the same. In such a |
| 159 // case, do not remove the "old" style sheet, because it is in fact the new | 159 // case, do not remove the "old" style sheet, because it is in fact the new |
| 160 // style sheet now. | 160 // style sheet now. |
| 161 if (oldStyleSheet && oldStyleSheet != styleSheet) | 161 if (oldStyleSheet && oldStyleSheet != styleSheet) |
| 162 removeStyleSheet(tabId, frameId, oldStyleSheet); | 162 removeStyleSheet(tabId, frameId, oldStyleSheet); |
| 163 | 163 |
| 164 frame.injectedStyleSheets.set(groupName, styleSheet); | 164 // The standard style sheet is ~660 KB per frame (as of Adblock Plus 3.3.2). |
| 165 // Keeping it in memory would only really be useful on Firefox, which allows |
| 166 // us to remove it via the tabs.removeCSS API. By choosing not to hold on to |
| 167 // it, we save potentially several megabytes per tab (#6967). |
| 168 if (groupName != "standard") |
| 169 frame.injectedStyleSheets.set(groupName, styleSheet); |
| 165 return true; | 170 return true; |
| 166 } | 171 } |
| 167 | 172 |
| 168 function getExecutableCode(script) | 173 function getExecutableCode(script) |
| 169 { | 174 { |
| 170 let code = executableCode.get(script); | 175 let code = executableCode.get(script); |
| 171 if (code) | 176 if (code) |
| 172 return code; | 177 return code; |
| 173 | 178 |
| 174 code = compileScript(script, [snippetsLibrarySource]); | 179 code = compileScript(script, [snippetsLibrarySource]); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, | 293 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, |
| 289 message.groupName, message.appendOnly); | 294 message.groupName, message.appendOnly); |
| 290 }); | 295 }); |
| 291 | 296 |
| 292 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"}) | 297 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"}) |
| 293 .then(response => response.ok ? response.text() : "") | 298 .then(response => response.ok ? response.text() : "") |
| 294 .then(text => | 299 .then(text => |
| 295 { | 300 { |
| 296 snippetsLibrarySource = text; | 301 snippetsLibrarySource = text; |
| 297 }); | 302 }); |
| OLD | NEW |