Skip to content
This repository

all() unusable if lazy loading after onload #85

danilobuerger opened this Issue · 3 comments

4 participants

Danilo Bürger trungson Altai Wills Bithrey
Danilo Bürger

If the scripts are added after the onload happens, the all() function will not work as it tries to attach to onload which already happend. Therefore the all function should be like this:

all : function (params) {
    if (this.readyState && (this.readyState !== "complete" || this.readyState !== "loaded")) {
        attachEvent(window,'load', function() { sh.highlight(params); });
    } else {

The alternative would be to explicitly document this and advise to use highlight() directly when after onload.


Another vote from me on this issue. all() does not work with AJAX


@danilobuerger, you should submit your fix so it can be pulled into the core.

Wills Bithrey

I've also just come across the same problem. I'm using SyntaxHighlighter in a Chrome extension where window.load has already fired when I'm calling SyntaxHighlighter. I'm currently calling SyntaxHighlighter.highlight(); instead of SyntaxHighlighter.all(); from my Chrome extension's content script to work around this issue.

Maybe it's just a documentation issue? Could the highlight method be exposed as a public API in addition to all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.