profiler for showing render statistics for web page? - javascript

I'm using a contrib drupal module that hooks into a form. Its presence appears to cause the jquery to render unreasonably slowly, but I'm not entirely sure about that.. I want to do some advanced troubleshooting on it, and I'm looking for a tool like xdebug that will give me an output file that I can view with KCacheGrind.
I've looked at Venkman and Firebug, but I don't want a debugging environment; I'm not at that point yet. I want to see a profile of the page load so I can see where the majority of the time was spent so I can identify where the problem is.
Edit: I'm actually not looking for a profile of the page load, as several folks have pointed out, but actually a profile of the javascript executed on a particular event. Firebug's debugger can grab the execution and step me into the code, but it just puts me at one point in the big ol' script. I think the slowdown involves loops and iterations, so I want to see a profile of the execution path.
Actually I think I should post this as a separate question.

In Firebug, click the "Net" tab. It lists every element it requests from the server, and detailed connection and load information (on hover) with a nice graphic display without hover.
Update
In addition, if actual page load isn't the issue, and you are indeed trying to profile Javascript, the Firebug "Console" tab probably has what you need.
Click "Profile" and then reload the page. Click "Profile" again to see a list of everything the javascript did with duration and timing information. This should show you what is taking the longest.

The chrome developer tools has a javascript profiler, that will profile all of the function calls on your page. The timeline feature (might only be in beta/dev versions) will show how much time the browser spends on various operations (layout and rendering for example) operations.
I believe that firebug also has a JS profiler.

There is a profiler in firebug in the console tab. Click once to start and second to stop the profiler. Chrome has also a profiler press ⌘⌥j. There is also a good profiling tool for internet explorer: dynaTrace ajax editon.
Btw. most of the time jquery is slow depends on wrong use of the selector engine.

Related

Will Firefox start my SDK extension automatically after the browser starts - loading screen

I am new on add-on development using the SDK.
I want to ask you guys if it is possible to start my extension automatically after I open my browser? At the moment I starts after I press my widget icon in the toolbar (the panel shows a table with some data I get from the DOM).
Another thing I want to ask you: is it possible to show a loading screen (like a ajax gif) inside my panel (my extension needs a few seconds after switching a tab, to get the DOM data) every time I press the toolbar button.
First of all: One question per post, please.
Extensions are always started with the browser. When it comes to SDK add-ons, your main.js will be called. It's your job to perform any additional initialization form there.
Panels contain regular HTML pages and therefore can use images.
It's impossible to tell you more, without you providing more details and the code you got so far!

Difference in browser behavior when clicking a link vs. copy-pasting it?

I'm curious what sort of difference there is in browser behavior when loading a page by clicking through a link vs. copy-pasting said link into the browser bar. Is there a general difference in the load process that I should know about?
I ask because I am working on an application using the Google Maps API, in which the user is able to create custom map links with a GPS location defined in the URL. The links work fine when copy-pasted into the browser; however, if the link is clicked directly, the browser generates a 'stack exceeded' exception (appropriate for this site!).
While I understand that generally we like to see code examples on Stack Overflow, I'm going to refrain from that for now - perhaps if anyone knows about differences in the DOM loading process between click and copy-paste, I can use that to narrow in on the issue without bogging down the discussion with tangentially-related code.
The same issue occurs in both Firefox and Chrome.
thanks!
Instead of copying and pasting the link, try right clicking and copying the link address. Basically, the links on a web page can display differently than they are.

Automated conditional browsing in background with chrome extension

I am researching the possibility that I might be able to use a Chrome extension to automate browsing and navigation (conditionally). My hope is that the extension can load a remote page (in the background) and inject a javascript to evaluate clickable links and click (by calling the click method) the appropriate (evaluated by some javascript logic) link, then repeat process for the resulting page.
My ability to javascript is not the problem - but I am struggling to discern whether (or not) a chrome extension can load pages in the back and inject script into them (making the DOM accessible).
I would be pleased if anyone could confirm (or deny) the ability to do so - and if so, some helpful pointers on where I should research next.
#Rob W - it seems the experimental features fit the bill perfectly. But my first tests seem to show the features are still very experimental ... ie. no objects get returned from callbacks:
background.html
function getAllosTabs(osTabs){
var x = osTabs;
alert(x.length); // error: osTabs is undefined
}
function createOffScreenTabCallback(offscreenTab){
document.write("offscreen tab created");
chrome.experimental.offscreenTabs.getAll(getAllosTabs);
alert(offscreenTab); // error: offscreenTab is undefined
}
var ostab = chrome.experimental.offscreenTabs.create({"url":"http://www.google.com"}, createOffScreenTabCallback)
alert(ostab); // error: ostab is undefined
Some further digging into the chromium source code on github revealed a limitation creating offscreenTab from background:
Note that you can't create offscreen tabs from background pages, since they
don't have an associated WebContents. The lifetime of offscreen tabs is tied
to their creating tab, so requiring visible tabs as the parent helps prevent
offscreen tab leaking.
So far it seems like it is unlikely that I can create an extension that browses (automatically and conditionally) in the background but I'll still keep trying - perhaps creating it from script in the popup might work. It won't run automatically at computer startup but it will run when the browser is open and the user clicks the browseraction.
Any further suggestions are highly welcome.
Some clarifications:
there's no "background" tabs except extension's background page (with iframes) but pages loaded in iframes can know they are being loaded in frames and can break or break at even the best counter-framebreaker scripts
offscreenTab is still experimental and is very much visible, as its intended use is different from what you need it for
content scripts, and chrome.tabs.update() are the only way handle the automated navigation part; aside being extremely harsh to program, problems and limitations are numerous, including CSP (Content-Security-Policy), their isolated context isolating event data, etc.
Alternatives... not many really. The thing is you're using your user's computer and browser to do your things and regardless of how dirty they are not, chrome's dev team still won't like it and will through many things at you and your extension (like the v2 manifest).
You can use NPAPI to start another instance chrome.exe --load-extension=iMacros.

Possible to run Javascript from address bar (bookmarklet) within Google Chrome's settings panel?

I would like to make a bookmarklet to open google chrome's settings panel and clear my cache with a single click.
For a while now, Ive had a bookmark that opens chrome's settings panel with the 'clear cache' setting already selected. After clicking the bookmark (normally opening it in a new tab) I have to then opent the tab and submit the form. However, when developing this is a task I have to do quite often and these several repeated steps just seem unnecessary.
This link opens the page to clear one's cache (obviously for Chrome users only): chrome://chrome/settings/clearBrowserData#cache
I recently discovered bookmarklets and thought it would be a good way to accomplish the task of clearing my cache with a single click. However, I've discovered that putting even a basic javascript sample in the address bar when on the settings page (linked above) fails to work.
For example, this works in the address bar on any given page, but not from the chrome settings page:
javascript:alert('hello stackoverflow');
Is there a way to execute javascript from the chrome settings page? Are there other options? Im looking for any route to achieve this goal and would love to learn something along the way, even if it means doing some evil. :)
add a bookmark:
javascript:document.write('<form onsubmit="window.open(\'javascript:\'+js_line.value, \'target\');return false;">javascript:<input type=text name=js_line style="width:90%;"/></form><iframe src="" name="target" style="width:100%;height:90%;"/>');
What you want might not be fully possible through a bookmarklet, but it's certainly possible with a Chrome App. There is an app Clear Cache already. I find it pretty useful.

Javascript: want to run my Bookmarklet infinite time

I have one boomarklet, means javascript code that takes current page's source, search for one string (or i can say hyperlink) and changes the current page to gathered link.
The problem is that
i want to make it run infinite times, if possible pausing in between to let the page load.
This is for just one of RPG i am playing, i am bored of Clicking that Exchange Flower link
again and again and again.
and its not offensive, or i ca say not ethical, they have many bookmarklets for doing some other kinda work, so ..
here is the Code
javascript:window.location.href=document.documentElement.innerHTML.substring(document.documentElement.innerHTML.indexOf("museum.php?rfc="),document.documentElement.innerHTML.indexOf("museum.php?rfc=")+18)+"&step=a2";
Thanks anyway...
It seems like you are asking about running some javascript on page load, since the script is navigating the page. Tools like Greasemonkey (for Firefox) are built for just this.
For Google Chrome, you could try this tool which converts bookmarklets into extensions.

Categories