I am writing a post on HTML. Afcorse the post will have Codes
in it. So for showing results in the post, I am taking help of JSFiddle, by embedding results of the code.
JSFiddle gives two methods for embedding results:
Script
<script async src="//jsfiddle/o7usdL0a/embed/result/"></script>
IFrame
<iframe width="100%" height="300" src="//jsfiddle/o7usdL0a/embedded/result/" allowfullscreen="allowfullscreen" allowpaymentrequest frameborder="0"></iframe>
My question is which method should be recommended for embedding results? (Script/IFrame)? Why?
Does any of the above method affect my site performance?
Is there any other alternative method/plugin which will be more fast and better than the above two methods?
I am writing a post on HTML. Afcorse the post will have Codes
in it. So for showing results in the post, I am taking help of JSFiddle, by embedding results of the code.
JSFiddle gives two methods for embedding results:
Script
<script async src="//jsfiddle/o7usdL0a/embed/result/"></script>
IFrame
<iframe width="100%" height="300" src="//jsfiddle/o7usdL0a/embedded/result/" allowfullscreen="allowfullscreen" allowpaymentrequest frameborder="0"></iframe>
My question is which method should be recommended for embedding results? (Script/IFrame)? Why?
Does any of the above method affect my site performance?
Is there any other alternative method/plugin which will be more fast and better than the above two methods?
The recommended method for embedding iframes is using the <iframe>
tag. It makes for better syntax and also allows you to control the iframe much better.
For example, you are able to remove an iframe's border, control scrolling options, etc.
<iframe src="//jsfiddle/o7usdL0a/embed/result/" style="width: 100%; height: 300px"
scrolling="no" marginwidth="0" marginheight="0" frameborder="0">
</iframe>
The <script async>
and the <iframe>
methods are both the same when it comes to site performance as they are both asynchronous. If you use the tag it will load asynchronously by default, so no need to worry about blocking code.