本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)75k · #2900

javascript-inline

できること

このスキルは、onclick属性のようにHTMLに直接書かれたJavaScriptを確認します。コードを整理し、セキュリティを高めたい開発者向けです。

使う場面

  • ✓HTMLにonclickやonmouseoverの属性があるとき。
  • ✓サイトのコンテンツセキュリティポリシーがインラインスクリプトをブロックしているとき。
  • ✓スクリプトを複数のページで共有してキャッシュさせたいとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/javascript-inline/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/javascript-inline/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私のHTMLページのインラインJavaScriptを別ファイルに移してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、インラインのイベントハンドラーやスクリプトブロックを見つけ、addEventListenerを使った外部ファイルへの移動を提案します。必要な場合のみ、表示領域の最初に見える重要なコードをインラインに残します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Avoid inline JavaScript

Inline JavaScript breaks browser caching, violates Content Security Policy (CSP), and creates unmaintainable spaghetti code mixing markup with behavior.

Quick Reference

  • Move onclick/onmouseover handlers to external JS files
  • Use addEventListener instead of inline event handlers
  • Exception: critical above-the-fold JS can be inlined
  • External files enable browser caching across pages

Check

Verify that JavaScript code is not mixed with HTML markup using external script files and proper separation of concerns for better maintainability and performance.

Fix

Move inline JavaScript to external files, implement proper event handling, and use modern JavaScript patterns for DOM interaction.

Explain

Explain why separating JavaScript from HTML improves maintainability, enables caching, reduces security risks, and follows best practices for separation of concerns.

Code Review

Review scripts, client components, and browser execution paths related to Avoid inline JavaScript. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/javascript-inline

よくある質問

インラインJavaScriptが問題になるのはなぜですか?

このスキルによると、別々にキャッシュできず、コンテンツセキュリティポリシーと衝突することがあり、マークアップと動作が混ざってしまいます。

onclickの代わりに何を使いますか?

このスキルは、外部のスクリプトファイルでのaddEventListenerを提案しています。

インラインJavaScriptが許される場合はありますか?

このスキルによると、表示領域の最初に必要な重要なJavaScriptは例外としてインラインに置けます。

詳細

作者による元の説明

Use when reviewing scripts, client components, bundles, or runtime behavior related to Avoid inline JavaScript. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#2900
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル