Ankur Shah
Ankur Shah

Reputation: 831

extra texts in javascript mime-type (Other than several recognized js mime types)

While inspecting the source code of this website: http://www.flipkart.com/ , I found this line <script type="text/javascript+fk-onload"> . I know there are many different mime types for javascript but this one has some added texts that goes over my mind. Could anyone explain the purpose of this extra text and when can it be used?

Upvotes: 0

Views: 170

Answers (1)

Bergi
Bergi

Reputation: 664969

The +-suffix defines a subtype. They are using it to execute that particular script onload:

FKART.utils.runOnload = function(a) {
    FKART.utils.runSnippet("fk-onload", a)
};
FKART.utils.runSnippet = function(a, c) {
    c = c || "script[type='text/javascript+" + a + "']";
    $(c).each(function() {
        var d = $(this);
        if (d.attr("data-src")) {
            $script(d.attr("data-src"), b.curry(this))
        }
        else {
            b(this)
        }
    });
    function b(d) {
        FKART.utils.evalScript(d.text || d.textContent || d.innerHTML);
        d.type = d.type + "-executed"
    }
};

Upvotes: 1

Related Questions