What does a script-Tag with src AND content mean?

后端 未结 4 762
执笔经年
执笔经年 2020-11-22 06:42

Example from Googles +1 button:



        
4条回答
  •  半阙折子戏
    2020-11-22 07:00

    Different browsers treat this differently. Some run the content only if the src is included without error. Some run it after attempting to include the src script, regardless of success. Since this behaviour is unreliable (and prohibited in HTML5), it should be avoided.

    Google isn't relying an any specific behaviour. Since the content is just an object literal (a value), executing it would not actually do anything except cause a silent error. Google's code looks at the contents of the script tag itself, and adjust its behaviour based on that.

提交回复
热议问题