Naming convention for assets (images, css, js)?

前端 未结 9 593
孤城傲影
孤城傲影 2021-01-29 20:33

I am still struggling to find a good naming convention for assets like images, js and css files used in my web projects.

So, my current would be:

CSS:

9条回答
  •  不思量自难忘°
    2021-01-29 20:48

    For large sites where css might define a lot of background images, a file naming convention for those assets comes in really handy for making changes later on.

    For example:

    [component].[function-description].[filetype]
    
    footer.bkg-image.png
    footer.copyright-gradient.png
    

    We have also discussed adding in the element type, but im not sure how helpful that is and could possibly be misleading for future required changes:

    [component].[element]-[function-description].[filetype]
    footer.div-bkg-image.png
    footer.p-copyright-gradient.png
    

提交回复
热议问题