HTML where to put the script

In SEO & WEB
May 03, 2023
HTML where to put the script

HTML where to put the script

In HTML, scripts are typically added to a web page using the <script> tag. The <script> tag is an HTML element used to define a client-side script that is executed within the web browser.

Here are some common ways to include a script in an HTML file:

Inline Script: The script can be added directly within the HTML code of the web page, using the <script> tag. For example:

<script>
// JavaScript code goes here
</script>

External Script: The script can be added to a separate JavaScript file and included in the HTML document using the <script> tag with the src attribute. For example:

<script src=”path/to/your/script.js”></script>

Defer Attribute: The defer attribute can be added to the <script> tag to indicate that the script should be executed after the HTML document has been parsed. For example:

<script src=”path/to/your/script.js” defer></script>

Async Attribute: The async attribute can be added to the <script> tag to indicate that the script should be executed asynchronously, without blocking the rendering of the page. For example:

<script src=”path/to/your/script.js” async></script>

These are some common ways to add scripts to an HTML file. The placement of the <script> tag within the HTML code depends on the specific requirements of the script and the desired functionality of the web page.

ایچ ٹی ایم ایل, جہاں اسکرپٹ ڈالنا ہے۔

ایچ ٹی ایم ایل میں، اسکرپٹ کو عام طور پر اسکرپٹ ٹیگ کا استعمال کرتے ہوئے ویب پیج میں شامل کیا جاتا ہے۔ اسکرپٹ ٹیگ ایک ایچ ٹی ایم ایل عنصر ہے جو کلائنٹ سائڈ اسکرپٹ کی وضاحت کے لیے استعمال ہوتا ہے جو ویب براؤزر کے اندر عمل میں آتا ہے۔

ایچ ٹی ایم ایل فائل میں اسکرپٹ کو شامل کرنے کے کچھ عام طریقے یہ ہیں

ان لائن اسکرپٹ: اسکرپٹ کو اسکرپٹ ٹیگ کا استعمال کرتے ہوئے براہ راست ویب پیج کے ایچ ٹی ایم ایل کوڈ میں شامل کیا جاسکتا ہے۔ مثال کے طور پر

<script>
// JavaScript code goes here
</script>

بیرونی اسکرپٹ: اسکرپٹ کو ایک علیحدہ جاواسکرپٹ فائل میں شامل کیا جا سکتا ہے اور ایس آر سی وصف کے ساتھ اسکرپٹ ٹیگ کا استعمال کرتے ہوئے ایچ ٹی ایم ایل دستاویز میں شامل کیا جا سکتا ہے۔ مثال کے طور پر:

<script src=”path/to/your/script.js”></script>

ڈیفر انتساب: ڈیفر انتساب کو اسکرپٹ ٹیگ میں شامل کیا جا سکتا ہے اس بات کی نشاندہی کرنے کے لیے کہ ایچ ٹی ایم ایل دستاویز کو پارس کرنے کے بعد اسکرپٹ کو عمل میں لایا جانا چاہیے۔ مثال کے طور پر:

<script src=”path/to/your/script.js” defer></script>

اسینک انتساب: اسینک انتساب کو اسکرپٹ ٹیگ میں شامل کیا جا سکتا ہے تاکہ اس بات کی نشاندہی کی جا سکے کہ صفحہ کی رینڈرنگ کو مسدود کیے بغیر، اسکرپٹ کو متضاد طور پر عمل میں لایا جانا چاہیے۔ مثال کے طور پر

<script src=”path/to/your/script.js” async></script>

یہ ایچ ٹی ایم ایل فائل میں سکرپٹ شامل کرنے کے کچھ عام طریقے ہیں۔ ایچ ٹی ایم ایل کوڈ کے اندر اسکرپٹ ٹیگ کی جگہ کا انحصار اسکرپٹ کی مخصوص ضروریات اور ویب صفحہ کی مطلوبہ فعالیت پر ہوتا ہے۔

/ Published posts: 1190

Shagufta Naz is a Multi-disciplinary Designer who is leading NewzFlex Product Design Team and also working on the Strategic planning & development for branded content across NewzFlex Digital Platforms through comprehensive research and data analysis. She is currently working as the Principal UI/UX Designer & Content-writer for NewzFlex and its projects, and also as an Editor for the sponsored section of NewzFlex.

Twitter
Facebook
Youtube
Linkedin
Instagram