What are alternatives to [removed]?

后端 未结 10 2028
北荒
北荒 2020-11-22 05:11

In tutorials I\'ve learnt to use document.write. Now I understand that by many this is frowned upon. I\'ve tried print(), but then it literally sen

10条回答
  •  悲&欢浪女
    2020-11-22 05:37

    Just dropping a note here to say that, although using document.write is highly frowned upon due to performance concerns (synchronous DOM injection and evaluation), there is also no actual 1:1 alternative if you are using document.write to inject script tags on demand.

    There are a lot of great ways to avoid having to do this (e.g. script loaders like RequireJS that manage your dependency chains) but they are more invasive and so are best used throughout the site/application.

提交回复
热议问题