Why do facebook and google pages have strange ids and classes?

烈酒焚心 提交于 2019-12-12 02:08:32

问题


Many a times I have inspected element on facebook and google pages but their page always have strange values as ids and classes in their html elements. Have a look at

Attributes of an element on facebook page

Attributes of element on google plus page

Q1. Is this result of some kind of obfuscation algorithm ?

It would be a nightmare to code with such attributes if devs actually use them which I don't think so.

Q2. Why are they doing it ?


回答1:


it's likely that they generate new classes and ids with each time the build is run to avoid having caching issues... this would be something thats done via the build and not defined by the developers




回答2:


Other answers partially answer this. Its not to deal with caching. Its not to avoid hackers, just makes their work a little more fun. Its mainly to reduce page size and improve bandwidth use. Its called js minifying. Its automated before publishing the code. It can be a pain to debug but there are tools to unminify which help. Also using 'caja' or closure compiler also causes this and provides protection from the js itself.



来源:https://stackoverflow.com/questions/22241329/why-do-facebook-and-google-pages-have-strange-ids-and-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!