Difference between g:include_scripts and g:requires?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2015 09:19 AM
Hi,
I was working over UI Pages and needs to include a custom js. It's pretty simple I know, I included g:requires tag to call my custom js. But suddenly, it clicked me that I can do the same thing using g:include_scripts tag as well.
I tried to find more over these but only info I got is that both are used to call js/css.
But still confused over their differences?
--
Cheers,
AR
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2015 09:24 AM
Hi Akash,
Please refer section 2 in the below link for more on g:requires
http://wiki.servicenow.com/index.php?title=Content_Management_and_Jelly#gsc.tab=0
section 9 for g:include_scripts
http://wiki.servicenow.com/index.php?title=Extensions_to_Jelly_Syntax#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2015 12:41 PM
Thanks Pradeep. But these links actually reveal about information of their usage.
But hey, thanks anyways.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2015 11:56 AM
Hi Akash, what a great question!! I learned something new through it today. thank you!
I believe the answer is found within the include_script macro. In a nutshell, they're are the same, yet, it appears that ServiceNow is trying to move away of <g:include_script> and instead promoting the use of <g:requires>.
In other words, always use <g:requires> instead of <g:include_script>. (ServiceNow says so... )
Below I paste the code that can be found in the "include_script" macro:
Macro: include_script
Description:
DO NOT USE THIS MACRO.
Use 'g:requires name="name"' instead.
This macro has been left here for backwards compatibility.
XML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!--
DO NOT USE THIS MACRO.
Use 'g:requires name="name"' instead.
This macro has been left here for backwards compatibility.
-->
<g:macro src="" />
<g:requires name="${jvar_src}" />
</j:jelly>
Thanks,
Berny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2015 12:44 PM
Hi Berny,
Thanks for the macro information. I also did some R&D and it comes out that all you was right but there is a single difference.
g:include_scripts is only used for calling js (UI Scripts) not for css(.cssdbx) but on the other hand g:requires can be used both.
I tried it and found that. I may be wrong about this but that all we have.
Anyways Thanks for the information.
--
Cheers,
AR