Relative path or url for html src and href attributes

前端 未结 4 1944
天涯浪人
天涯浪人 2020-12-12 02:32

Using a framework makes it easy to list full url\'s for my html src and href attributes, and I feel I\'m being more thorough by listing a full url instead of a relative path

4条回答
  •  清歌不尽
    2020-12-12 03:19

    Oh you really don't want to use a full path. You'll have a lot of work ahead of you:

    • If you want to develop the site locally
    • You change / add domains (development, staging, etc)
    • You switch to using a CDN

    You also will break your dev environment, since most modern ones will perform local directory lookups. Can't do that with a domain.

    Also, in a dev environment you will be pulling from the production site, which will make modifying and adding images extremely tricky.

    Most importantly, other developers working with your code will try to kill you. And that's bad for your health.

提交回复
热议问题