JS Heap recommended memory size

Is there any limit to the heap size in the chrome memory profile ? Note: This is a Chrome only answer, see below why. You should take a look at window.performance.memory in Chrome Dev Tools, there is a jsHeapSizeLimit attribute. However, I'm not sure this will be the maximum value on any memory profiling y-axis You can find more informations on MDN : https://developer.mozilla.org/en-US

JS堆建议的内存大小

Chrome内存配置文件中的堆大小是否有限制? 注意:这是Chrome的唯一答案,请参阅下面的原因。 您应该查看Chrome开发工具中的window.performance.memory ,它有一个jsHeapSizeLimit属性。 但是,我不确定这将是任何内存分析y轴上的最大值 您可以在MDN上找到更多信息:https://developer.mozilla.org/en-US/docs/Web/API/Window/performance performance.memory : Chrome中添加了非标准扩展程序。 在MDN中链接:htt

Redefinition of Promise

Promise is now a global reserved word in es6 and linters throw a error. So what are the pitfalls of doing this var Promise = require("bluebird"); or should i do var BluebirdPromise = require("bluebird"); Looks like there isn't a problem to redeclaring promise as long as it's not global. But second one is a better approach Many of us do that. There's no problem. You're ju

承诺的重新定义

Promise现在是es6中的全局保留字,而linters会抛出错误。 那么做这件事有什么缺陷 var Promise = require("bluebird"); 或者我应该这样做 var BluebirdPromise = require("bluebird"); 看起来,只要不是全球性的,重新宣布承诺就没有问题。 但第二个是更好的方法 我们中的许多人都这样做。 这里没有问题。 你只是使用更快的实现,就是这样。 但请注意,您可能会使用各种图书馆提供的越来越多的承诺,因此这是一个非常

Xpath with js and google chrome

I have a code for generating xpath on click but i need to put that in an chrome extension. So how to do that? Here is the code for generating xpath on click: function get_XPath(elt) {var path = ''; for (; elt && elt.nodeType==1; elt=elt.parentNode) {var idx=$(elt.parentNode).children(elt.tagName).index(elt)+1; idx>1 ? (idx='['+idx+']'

带有js和谷歌浏览器的Xpath

我有一个代码用于生成点击xpath,但我需要把它放在一个Chrome扩展中。 那么该怎么做? 这里是点击生成xpath的代码: function get_XPath(elt) {var path = ''; for (; elt && elt.nodeType==1; elt=elt.parentNode) {var idx=$(elt.parentNode).children(elt.tagName).index(elt)+1; idx>1 ? (idx='['+idx+']') : (idx=''); path='/'+elt.tagName

Is there a JavaScript/jQuery DOM change listener?

Essentially I want to have a script execute when the contents of a DIV change. Since the scripts are separate (content script in chrome extension & webpage script), I need a way simply observe changes in DOM state. I could set up polling but that seems sloppy. The old contents of this answer is now deprecated. See the other answers based on MutationObserver . Several years later, ther

是否有JavaScript / jQuery DOM更改侦听器?

基本上我想在DIV的内容发生变化时执行脚本。 由于脚本是分开的(Chrome扩展和网页脚本中的内容脚本),因此我需要一种简单的方式观察DOM状态的变化。 我可以设置投票,但似乎马虎。 此答案的旧内容现已被弃用。 查看基于MutationObserver的其他答案。 几年后,现在有了一个更好的解决方案。 DOM4突变观察者是不推荐的DOM3突变事件的替代品。 它们目前在现代浏览器中被实现为MutationObserver (或者作为旧版Chrome中的

Enable chrome extension without clicking

How to enable chrome extension without clicking it. I need to perform a certain function from my extension every time i reload a page(no clicking) is there a way to do it. My code which contains the on click method chrome.extension.onMessage.addListener(function(request, sender) { if (request.action == "getSource") { message.innerText = request.source; } }); function onWindowLoad()

无需点击即可启用Chrome扩展

如何在不点击的情况下启用Chrome扩展。 我需要从我的扩展中执行某个功能,每当我重新加载一个页面(不点击)有办法做到这一点。 我的代码包含点击方法 chrome.extension.onMessage.addListener(function(request, sender) { if (request.action == "getSource") { message.innerText = request.source; } }); function onWindowLoad() { var message = document.querySelector('#message'); chrome.tabs.exec

How do I refresh/reload a Chrome Extension?

I'm developing an extension in Chrome 4 (currently 4.0.249.0) that will show the user's StackOverflow/SuperUser/ServerFault reputation in the status bar. I've designed an options page to get the user's profile IDs and I save them to localStorage and read them well in the extension. It all works great. The problem is I cannot find a (programmatic) way to refresh the extension u

如何刷新/重新加载Chrome扩展程序?

我正在开发Chrome 4中的扩展程序(当前为4.0.249.0),它将在状态栏中显示用户的StackOverflow / SuperUser / ServerFault信誉。 我设计了一个选项页面以获取用户的配置文件ID,并将它们保存到localStorage并在扩展中很好地读取它们。 这一切都很好。 问题是我找不到(程序化)的方式来刷新选项保存的扩展名。 我试着调用location.reload(); 从扩展页面本身点击右键 - 无济于事。 我进一步追求它,并试图查看Chrome的chro

Unit Testing Chrome Extensions?

This question already has an answer here: How to test chrome extensions? 5 answers If you are asking about unit testing, it will be same as any other javascript code. Remember unit tests should be as small as possible and they shouldn't touch (they can mock) any external API. If you are asking about integration testing, than its a different matter.

单元测试Chrome扩展?

这个问题在这里已经有了答案: 如何测试Chrome扩展? 5个答案 如果您询问单元测试,它将与其他JavaScript代码相同。 记住单元测试应该尽可能小,并且不应该碰到(他们可以模拟)任何外部API。 如果你问的是集成测试,那么比另一回事。

Localstorage not working

I'm writing a Chrome extension that uses a content script to modify certain parts of a website. The content script worked fine until I tried to add an options page to my extension. Right now I'm using an options.html file to save user preferences to localstorage, as you can see here: <html> <head><title>Options</title></head> <script ty

本地存储不起作用

我正在编写一个Chrome扩展程序,它使用内容脚本来修改网站的某些部分。 内容脚本工作正常,直到我试图将选项页面添加到我的扩展。 现在,我使用options.html文件将用户首选项保存到localstorage,如下所示: <html> <head><title>Options</title></head> <script type="text/javascript"> function save_options() { var select = document.getEle

How to terminate script execution when debugging in Google Chrome?

When stepping through JavaScript code in Google Chrome debugger, how do I terminate script execution if I do not want to continue? The only way I found is closing the browser window. Pressing "Reload this page" runs the rest of the code and even submits forms as if pressing F8 "Continue". UPDATE : When pressing F5 (Refresh) while a script is paused: Google Chrome (v22

如何在Google Chrome中进行调试时终止脚本执行?

在Google Chrome调试器中逐句浏览JavaScript代码时,如果我不想继续执行,如何终止脚本执行? 我发现的唯一方法是关闭浏览器窗口。 按下“重新加载此页面”运行代码的其余部分,甚至提交表格,就像按F8“继续”一样。 更新 : 在脚本暂停时按F5键(刷新): Google Chrome(v22)运行脚本。 如果脚本提交HTTP请求,则显示该请求的HTTP响应。 原始页面未刷新。 IE 9只是冻结。 然而IE有一个选项“停止调试”,当按下时(

highlight HTML inside JavaScript strings in Sublime

Is there any Sublime package to syntax-highlight HTML inside JavaScript strings? (Note the question is only about HTML inside JS strings, not syntax highlighting in general.) Specifically I am writing Angular components using inline templates angular.module('compMod', []).component('myComp', { template: `<div>Some Text</div>` }); and looking to highlight HTML syntax inside t

突出显示Sublime中JavaScript字符串中的HTML

是否有任何Sublime包在JavaScript字符串中进行语法高亮HTML? (注意这个问题只是关于JS字符串中的HTML,而不是一般的语法高亮。) 具体来说,我正在使用内联模板编写Angular组件 angular.module('compMod', []).component('myComp', { template: `<div>Some Text</div>` }); 并希望突出显示ES6模板字符串中的HTML语法。 正如@卡尔文在上面评论的那样,我不会说这是一种很好的做法,但我不一定会说这是