- Now the question arises, can we get rid of these extra divs?
- Will they be generated every time?
- If we can remove these extra divs, how can we do that?
Yes, we can remove these extra divs and it totally depends on our coding practices. Most of the time developers don’t care about these divs and write their code, but these extra divs make our HTML bulky as the size of HTML increases, it increases network traffic, and the performance of our site decreases. Because of these divs, most of the developers always face CSS issues.
For removing these extra divs you have to include these lines of code in your component level. These lines are-
if(WCMMode.fromRequest(request) != WCMMode.EDIT){
IncludeOptions.getOptions(request,true).setDecorationTagName(“”);
}
We have to import these two statement for WCMMode and includeOptions–
@page import=”com.day.cq.wcm.api.WCMMode”
@page import=”com.day.cq.wcm.api.components.IncludeOptions”
Q4). Now another question arises where to add these lines?
The best practice is that you must put these lines in your global.jsp. So that all of your project components have these lines of code available to them.
So that if you sling:include or cq:include any of these components then no extra div will be generated.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.