Is there a reason to use JavaScript library plugins in grails that provide this library through TagLibs rather than just using it directly?

If you are browsing the grails plugin site, you will find many plugins for jQuery and other JavaScript libraries. Most of them open this JavaScript library through Grails TagLibs. This is truly an advantage, and if so, why?

+4
source share
3 answers

Personally, I prefer to use JavaScript tags for JavaScript. For example, if you want to create a link that sends an AJAX request and updates the DIV with a response, it’s easier for me to write

<g:remoteLink action="show" id="1" update="myDiv" onLoading="showSpinner();">Click Me</g:remoteLink> 

than the corresponding javascript.

If you have the JQuery plugin installed and you decide to replace JQuery with a prototype (for example), the tags above should work as soon as you replace the JQuery plugin with the Prototype plugin. This would not be possible if you just copied .js files to web-app/js (instead of using plugins).

Ultimately, if you use JS plugins, your application "knows" which JS libraries are using. Other plugins (e.g. resources ) can then use this information to your advantage.

+2
source

To answer your real question about whether using TagLibs is an option to display JavaScript is an advantage, my answer will usually be negative. But you are likely to get as many people who disagree with me as those who agree. Especially the people who took the time to create these TagLibs.

It's just a lot easier for me to figure out JavaScript than using taglib. The only exceptions I could consider are grals with taglib removed, but I still don't use them personally.

+7
source

jQuery is just an extension in the javascript library. It does not offer any new features that Javascript does not offer. However, it makes your life a lot easier when you do things like (but not limited to)

  • Dom manipulation
  • Tree traversal
  • Ajax
  • And much more

It is not necessary when you just do something simple and small here or there. But most often, when you are doing a large project, it makes sense to enable jQuery (31 KB and 1 HTTP request) and use it to your advantage.

0
source

Source: https://habr.com/ru/post/1380044/


All Articles