document.currentScript를 사용한 인라인 렌더링
document.currentScript를 사용한 인라인 렌더링 Lean Rada는 document.currentScript 속성을 활용한 깔끔한 트릭을 소개합니다. 이를 이용해 페이지가 로드될 때 스스로 교체되는 작은 인라인 <script> 요소를 삽입할 수 있습니다: 올해는 <script> document.currentScript.replaceWith( new Date().getFullYear())</script>입니다. 다음과 같은 단축 함수를 정의한다면: $=(...n)=>document.currentScript.replaceWith(...n) 그러면 간단한 템플릿 언어를 얻게 됩니다: 올해는 <script>$(new Date().getFullYear())</script>입니다. 태그: javascript