Difference between g:include_scripts and g:requires?

Artemis15
Kilo Guru

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

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Thanks Pradeep. But these links actually reveal about information of their usage.



But hey, thanks anyways.


bernyalvarado
Mega Sage

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


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